import 'package:tender_flutter/page/home/model/market_entity.dart';

marketEntityFromJson(MarketEntity data, Map<String, dynamic> json) {
	if (json['pageNum'] != null) {
		data.pageNum = json['pageNum'] is String
				? int.tryParse(json['pageNum'])
				: json['pageNum'].toInt();
	}
	if (json['pageSize'] != null) {
		data.pageSize = json['pageSize'] is String
				? int.tryParse(json['pageSize'])
				: json['pageSize'].toInt();
	}
	if (json['total'] != null) {
		data.total = json['total'] is String
				? int.tryParse(json['total'])
				: json['total'].toInt();
	}
	if (json['pages'] != null) {
		data.pages = json['pages'] is String
				? int.tryParse(json['pages'])
				: json['pages'].toInt();
	}
	if (json['list'] != null) {
		data.xList = new List<MarketList>();
		(json['list'] as List).forEach((v) {
			data.xList.add(new MarketList().fromJson(v));
		});
	}
	if (json['isFirstPage'] != null) {
		data.isFirstPage = json['isFirstPage'];
	}
	if (json['isLastPage'] != null) {
		data.isLastPage = json['isLastPage'];
	}
	return data;
}

Map<String, dynamic> marketEntityToJson(MarketEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['pageNum'] = entity.pageNum;
	data['pageSize'] = entity.pageSize;
	data['total'] = entity.total;
	data['pages'] = entity.pages;
	if (entity.xList != null) {
		data['list'] =  entity.xList.map((v) => v.toJson()).toList();
	}
	data['isFirstPage'] = entity.isFirstPage;
	data['isLastPage'] = entity.isLastPage;
	return data;
}

marketListFromJson(MarketList data, Map<String, dynamic> json) {
	if (json['area'] != null) {
		data.area = json['area'].toString();
	}
	if (json['infoType'] != null) {
		data.infoType = json['infoType'].toString();
	}
	if (json['typeCode'] != null) {
		data.typeCode = json['typeCode'] is String
				? int.tryParse(json['typeCode'])
				: json['typeCode'].toInt();
	}
	if (json['infoTypeCode'] != null) {
		data.infoTypeCode = json['infoTypeCode'] is String
				? int.tryParse(json['infoTypeCode'])
				: json['infoTypeCode'].toInt();
	}
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	if (json['money'] != null) {
		data.money = json['money'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['company'] != null) {
		data.company = json['company'].toString();
	}
	if (json['isTop'] != null) {
		data.isTop = json['isTop'];
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['status'] != null) {
		data.status = json['status'] is String
				? int.tryParse(json['status'])
				: json['status'].toInt();
	}
	if (json['remark'] != null) {
		data.remark = json['remark'].toString();
	}
	if (json['num'] != null) {
		data.num = json['num'].toString();
	}
	if (json['title'] != null) {
		data.title = json['title'].toString();
	}
	if (json['createDate'] != null) {
		data.createDate = json['createDate'].toString();
	}
	return data;
}

Map<String, dynamic> marketListToJson(MarketList entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['area'] = entity.area;
	data['infoType'] = entity.infoType;
	data['typeCode'] = entity.typeCode;
	data['infoTypeCode'] = entity.infoTypeCode;
	data['type'] = entity.type;
	data['money'] = entity.money;
	data['name'] = entity.name;
	data['company'] = entity.company;
	data['isTop'] = entity.isTop;
	data['id'] = entity.id;
	data['status'] = entity.status;
	data['remark'] = entity.remark;
	data['num'] = entity.num;
	data['title'] = entity.title;
	data['createDate'] = entity.createDate;
	return data;
}